package org.shoukaiseki.tools.mybatis.generator;


import java.sql.*;

/**
 * <br>
 *
 * @author 蒋カイセキ    Japan-Tokyo  18-10-22 下午7:22<br>
 * ブログ http://www.shoukaiseki.top/<br>
 * E-メール jiang28555@Gmail.com<br>
 **/
public class AppMain {
    // 数据库连接地址
     public static String URL="jdbc:mysql://192.168.0.198:3306/activitydb?serverTimezone=GMT";
     // 用户名
     public static String USERNAME="root";
     // 密码
     public static String PASSWORD="h666777kedou";
     // mysql的驱动类
     public static String DRIVER="com.mysql.cj.jdbc.Driver";

    Connection conn = null;

     public AppMain() throws Exception {
         init();
     }


     public void init() throws Exception {
         Class.forName(DRIVER);
         conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
     }


     public void test() throws Exception {
         String sql="select\n" +
                 "live_channel.live_channel_id, -- 直播频道ID\n" +
                 "live_channel.television_channel_id, -- 频道ID\n" +
                 "# live_channel.live_name, -- 直播名称\n" +
                 "live_channel.push_url, -- 推流地址\n" +
                 "live_channel.http_pull_url, -- http拉流地址\n" +
                 "live_channel.hls_pull_url, -- hls拉流地址\n" +
                 "live_channel.rtmp_pull_url, -- rtmp拉流地址\n" +
                 "live_channel.status live_channel_status, -- 0启用,1禁用\n" +
                 "live_channel.buyer_id, -- 主播ID,会员ID\n" +
                 "live_channel.retries, -- 重试次数\n" +
                 "live_channel.processing_type, -- 处理类型[1:新建频道,2:禁用频道]\n" +
                 "live_channel.processing_progress, -- 处理进度\n" +
                 "live_channel.live_telecast_id, -- 直播列表id[live_telecast.live_id]\n" +
                 "live_channel.service_status, -- 直播服务频道实际状态[（0：空闲； 1：直播； 2：禁用； 3：直播录制）]\n" +
                 "live_channel.transcode_pull_url, -- 拉流转码地址\n" +
                 "live_telecast.seller_id, -- 商家id\n" +
                 "live_telecast.seller_account, -- 商家账号\n" +
                 "live_telecast.live_name, -- 直播名称\n" +
                 "live_telecast.live_position, -- 直播位置\n" +
                 "live_telecast.main_picture, -- 直播主图\n" +
                 "live_telecast.start_time, -- 直播开始时间\n" +
                 "live_telecast.end_time, -- 直播结束时间\n" +
                 "live_telecast.open_status, -- 关闭/打开 【0：关闭，1：打开】\n" +
                 "live_telecast.view_times, -- 观看次数\n" +
                 "live_telecast.order_count, -- 生成订单\n" +
                 "live_telecast.status, -- 直播状态 【0：未开播，1：直播中】\n" +
                 "live_telecast.operation, -- 操作状态 【0：未审核，1：已审核】\n" +
                 "live_telecast.create_time, -- 创建时间\n" +
                 "live_telecast.remarks, -- 直播备注\n" +
                 "live_telecast.del_status -- 是否删除 【0：未删除，1：删除】\n" +
                 "\n" +
                 "\n" +
                 "from live_channel ,live_telecast\n" +
                 "\n" +
                 "where live_channel.live_telecast_id=live_telecast.live_id";
         PreparedStatement ps =  conn.prepareStatement(sql);
         ResultSet rs = ps.executeQuery();
         ResultSetMetaData metaData = rs.getMetaData();
         for (int i = 0; i <metaData.getColumnCount() ; i++) {
             String columnLabel = metaData.getColumnName(i+1);
             System.out.println(columnLabel);

         }
     }

    public static void main(String[] args) throws Exception {
        AppMain appMain = new AppMain();
        appMain.init();
        appMain.test();
    }

}
